package com.laiketui.order.mapstruct;

import com.laiketui.order.api.dto.OrderOfflineExamineDTO;
import com.laiketui.order.api.dto.OrderParentDTO;
import com.laiketui.order.domain.OrderOfflineExamine;
import com.laiketui.order.domain.OrderParent;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Mapper
public interface OrderOfflineExamineMapstructMapper {
    OrderOfflineExamineMapstructMapper INSTANCE = Mappers.getMapper(OrderOfflineExamineMapstructMapper.class);

    OrderOfflineExamineDTO toDTO(OrderOfflineExamine offlineExamine);


    default List<OrderOfflineExamineDTO> toDTOs(List<OrderOfflineExamine> orderOfflineExamineList){
        if(CollectionUtils.isEmpty(orderOfflineExamineList)){
            return new ArrayList<>();
        }
        return orderOfflineExamineList.stream().map(this::toDTO).collect(Collectors.toList());
    }
}
